package com.dzsw.controller;

import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/multi")
public class MultipartController {


    @Value("${config.save-file-path}")
    private String saveFilePath;

    @PostMapping("/u1")
    public String upload1(MultipartFile file) throws IOException {
        FileUtil.writeFromStream(file.getInputStream(), saveFilePath + file.getOriginalFilename());
        return "upload success.";
    }
}
